﻿using AdminSystem.Applications;
using AdminSystem.Domain.User;
using AdminSystem.Write.API.Command.SlaughtersCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AdminSystem.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        public SlaughterController(IMediator mediator)
        {
            Mediator = mediator;
        }

        public IMediator Mediator { get; }


        /// <summary>
        /// 添加屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<ApiResult<object>> SlaughterAdd(SlaughterCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 查询屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public async Task<ApiResult<Slaughter>> SlaughterQuery()
        {
            SlaughterQueryCommand command = new SlaughterQueryCommand();
            return await Mediator.Send(command);
        }
    }
}